package com.erp.auto.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.erp.auto.domain.ErpAutoSpeciesCouponConfig;
import com.erp.auto.service.ErpAutoSpeciesCouponConfigService;
import com.ruoyi.common.core.domain.R;
import lombok.AllArgsConstructor;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 自动化店铺满减活动配置
 *
 * @author WXX
 * @date 2024-01-24 10:03:45
 */
@RestController
@AllArgsConstructor
@RequestMapping("/kjerp/erpAutoSpeciesCouponConfig" )
public class ErpAutoSpeciesCouponConfigController {

    private final ErpAutoSpeciesCouponConfigService erpAutoSpeciesCouponConfigService;


    @PostMapping("/saveConfig")
    public R<Object> saveConfig(@RequestBody ErpAutoSpeciesCouponConfig config) {

        // 创建活动
        return erpAutoSpeciesCouponConfigService.createSpeciesCouponActivity(config);
    }

    @GetMapping("/getSpeciesCouponList")
    public R<Object> getSpeciesCouponList() {
        List<ErpAutoSpeciesCouponConfig> list =
                erpAutoSpeciesCouponConfigService.list(new LambdaQueryWrapper<>());
        return R.ok(list);
    }

    @GetMapping("/selectById")
    public R<Object> selectById(@Param("id") Long id) {
        ErpAutoSpeciesCouponConfig byId = erpAutoSpeciesCouponConfigService.getById(id);
        return R.ok(byId);
    }

    /**
     * 禁用
     */
    @GetMapping("/stopActivity")
    public R<Object> stopActivity(@Param("id") Long id) {
        return erpAutoSpeciesCouponConfigService.stopActivity(id);
    }
}
